package com.sgb.knowledgeshare.viewmodel;

import androidx.lifecycle.ViewModel;
import com.sgb.knowledgeshare.ShareConfig;
import com.sgb.knowledgeshare.entity.TabelListEntity;
import com.sgb.knowledgeshare.view.activity.LabelDetailsActivity;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.view.entity.VideoListEntity;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by：冯齐 on 2021/1/29 10:33
 * Description：
 */
public class ShareLabelDetailsModel extends ViewModel {

    LabelDetailsActivity activity;

    public void setActivity(LabelDetailsActivity labelDetailsActivity) {
        activity = labelDetailsActivity;
    }

    //获取视频列表
    public void getVideLabelPage(int page,String no) {
        Map map = new HashMap();
        map.put("page",page);
        map.put("limit",10);
        map.put("labelNo",no);
        DialogHelper.showProgressDialog(activity, null, "加载中...", 0, true, null).setCanceledOnTouchOutside(false);
        ShareConfig.getInstance().getApi().getVideLabelPage(map).enqueue(new ICallBack<BaseEntity<VideoListEntity>>() {
            @Override
            public void onSuccess(BaseEntity<VideoListEntity> data) {
                DialogHelper.dismissProgressDialog();
                if (data.getData()==null)return;
                if (data.getState().equals("ok")){
                    activity.setVideLabelList(data.getData());
                }
            }
        });
    }
    //获取标签列表
    public void getLabelList(String searchName) {
        Map map = new HashMap();
        map.put("labelName", searchName);
        ShareConfig.getInstance().getApi().getLabelList(map).enqueue(new ICallBack<BaseEntity<List<TabelListEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<TabelListEntity>> data) {
                if (data.getData()==null)return;
                if (data.getState().equals("ok")){
                    activity.setLabelList(data.getData());
                }
            }
        });
    }

}
